package com.mind.adjust.controller;


import com.mind.adjust.service.AjRuleViewGroupService;
import com.mind.common.core.domain.AjaxResult;
import com.mind.common.log.annotation.Log;
import com.mind.common.log.enums.BusinessType;
import com.mind.common.utils.poi.ExcelUtil;
import com.mind.common.web.controller.BaseController;
import com.mind.common.web.page.TableDataInfo;
import com.mind.system.domain.AjRuleViewGroup;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 规则分组管理
 *
 * @author makejava
 * @DocView.PathPrefix {{host}}/api/operate
 * @since 2025-05-12 10:57:13
 */
@RestController
@RequestMapping("/adjust/ajRuleViewGroup")
@Tag(name = "规则分组管理")
public class AjViewGroupController extends BaseController {
    /**
     * 服务对象
     */
    @Autowired
    private AjRuleViewGroupService ajViewGroupService;

    /**
     * 获取列表
     *
     * @param AjRuleViewGroup 筛选条件
     * @return .com.mind.system.domain.AjRuleViewGroup
     */
    @Log(title = "规则分组列表", businessType = BusinessType.QUERY)
    @GetMapping("/list")
    @Operation(summary = "规则分组列表", description = "规则分组列表")
    public TableDataInfo list(
            @Parameter(description = "过滤参数", required = false)
            AjRuleViewGroup AjRuleViewGroup) {
        startPage();
        List<AjRuleViewGroup> list = ajViewGroupService.selectAjViewGroupList(AjRuleViewGroup);
        return getDataTable(list);
    }

    /**
     * 导出
     *
     * @param AjRuleViewGroup 筛选条件
     * @return 结果
     */
    @Log(title = "规则分组导出", businessType = BusinessType.EXPORT)
//    @RequiresPermissions("adjust:attachType:export")
    @Operation(summary = "规则分组导出", description = "规则分组导出")
    @PostMapping("/export")
    public void export(HttpServletResponse response, AjRuleViewGroup AjRuleViewGroup) {
        List<AjRuleViewGroup> list = ajViewGroupService.selectAjViewGroupList(AjRuleViewGroup);
        ExcelUtil<AjRuleViewGroup> util = new ExcelUtil<AjRuleViewGroup>(AjRuleViewGroup.class);
        util.exportExcel(response, list, "规则分组数据");
    }

    /**
     * 根据ID获取详情
     *
     * @return .com.mind.system.domain.AjRuleViewGroup
     */
//    @RequiresPermissions("operate:AjRuleViewGroup:query")
    @GetMapping(value = "/{ajViewGroupId}")
    public AjaxResult getInfo(@PathVariable Long ajViewGroupId) {
        return success(ajViewGroupService.selectAjViewGroupById(ajViewGroupId));
    }

    /**
     * 新增
     *
     * @return 结果
     */
//    @RequiresPermissions("operate:AjRuleViewGroup:add")
    @PreAuthorize("@ss.hasPermi('adjust:viewGroupService:add')")
    @Log(title = "规则分组新增", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody AjRuleViewGroup AjRuleViewGroup) {
        return toAjax(ajViewGroupService.insertAjViewGroup(AjRuleViewGroup));
    }

    /**
     * 修改
     *
     * @return 结果
     */
//    @RequiresPermissions("operate:AjRuleViewGroup:edit")
    @PreAuthorize("@ss.hasPermi('adjust:viewGroupService:edit')")
    @Log(title = "规则分组修改", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody AjRuleViewGroup AjRuleViewGroup) {
        return toAjax(ajViewGroupService.updateAjViewGroup(AjRuleViewGroup));
    }

    /**
     * 删除
     *
     * @return 结果
     */
//    @RequiresPermissions("operate:AjRuleViewGroup:remove")
    @PreAuthorize("@ss.hasPermi('adjust:viewGroupService:remove')")
    @Log(title = "规则分组删除", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ajViewGroupIds}")
    public AjaxResult remove(@PathVariable Long[] ajViewGroupIds) {
        return toAjax(ajViewGroupService.deleteAjViewGroupByIds(ajViewGroupIds));
    }

}


